/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package msn;
import Chat.Servidor;
import java.awt.event.*;
import javax.swing.*;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import msn.Cliente;

/**
 *
 * @author cart2r
 */



public class Ventana extends JFrame implements ActionListener {

    private JMenuBar menu;
	private JMenu accion;
	private JMenuItem conectar,crear,salir;
        private JTextArea areaChat;
        private Servidor s;
        private Cliente c;

        private JTextField texto;
	private JButton enviar,contactos;
	private JScrollPane scroll;
        private final static String newline = "\n";

	public Ventana(){
		super("Chat");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(400,300);

		this.componentes();

		this.setVisible(true);
	}

	public void componentes(){
		menu = new JMenuBar();
		this.setJMenuBar(menu);
		accion = new JMenu("Menu");
		menu.add(accion);
		conectar = new JMenuItem("Conectar");
		conectar.addActionListener(this);
		accion.add(conectar);
		crear = new JMenuItem("Crear Servidor");
		crear.addActionListener(this);
		accion.add(crear);
		salir = new JMenuItem("Salir");
		salir.addActionListener(this);
		accion.add(salir);

		this.setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.gridx = 0;
		gbc.gridy = 0;
		gbc.gridwidth = 2;
		gbc.gridheight = 1;
		gbc.fill = GridBagConstraints.BOTH;
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;
		areaChat = new JTextArea();
                areaChat.setEditable(false);
		scroll = new JScrollPane(areaChat);
		this.add(scroll,gbc);

		gbc.gridx=0;
		gbc.gridy=1;
		gbc.gridwidth=1;
		gbc.gridheight=1;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		gbc.weightx = 1.0;
		gbc.weighty = 0.0;
		texto = new JTextField(20);
		this.add(texto,gbc);
                texto.addActionListener(this);

		gbc.gridx=1;
		gbc.gridy=1;
		gbc.gridwidth=1;
		gbc.gridheight=1;
		gbc.fill = GridBagConstraints.NONE;
		gbc.weightx = 0.0;
		gbc.weighty = 0.0;
		enviar = new JButton("Enviar");
		enviar.addActionListener(this);
		this.add(enviar,gbc);



                gbc.gridx=1;
		gbc.gridy=1;
		gbc.gridwidth=1;
		gbc.gridheight=2;
		gbc.fill = GridBagConstraints.NONE;
		gbc.weightx = 0.4;
		gbc.weighty = 0.4;
                contactos = new JButton("BFF");
                contactos.addActionListener(this);
                 this.add(contactos,gbc);
	}

	public void actionPerformed(ActionEvent click) {



            }



            //else if(click.getActionCommand()) {
               // String text = texto.getText();
               // areaChat.append(text + newline);
               // areaChat.selectAll();
               // areaChat.setCaretPosition(areaChat.getDocument().getLength());
   // }






      public JTextArea getAreaChat() {
		return areaChat;
	}



}

